<?php
/**
 * Created by PhpStorm.
 * User: Lvyj
 * Date: 2017/6/27 0027
 * Time: 15:16
 */

namespace Admin\Assist\Controllers;

use Helpers\Assets;
use Helpers\Main;
use Helpers\Template;
use Admin\Assist\Service\AssistService as Assist;

class UsersController extends ControllerBase
{

    public function indexAction()
    {
        $this->view->pick("user/list");
        Assets::easyUI('js/user.js');
        Template::exists('user', 'list') or die(Main::showMessageModal('配置文件不存在，请先创建！', 109106002));
        $listSearchArr = array();
        $listSearchArr[] = array('type' => 'text', 'id' => 'List_Search', 'label' => ' 搜索： ');

        $this->view->setVars(array(
            'List' => Template::createList('List', 'user', [
                'searchToolbar' => Template::createSearchToolBar($listSearchArr, true)
            ])
        ));
    }

    public function devicesAction()
    {
        $this->view->pick('device/list');
        Assets::easyUI('js/device.js');
        Template::exists('device', 'list') or die(Main::showMessageModal('配置文件不存在，请先创建！', 109106002));
        $listSearchArr = array();
        $listSearchArr[] = array('type' => 'text', 'id' => 'List_Search', 'label' => ' 搜索： ');
        $userId = $this->request->get('id', 'int');
        $user = Assist::getUserInfo($userId);
        $this->view->setVars(array(
            'List' => Template::createList('List', 'device', [
                //'searchToolbar' => Template::createSearchToolBar($listSearchArr, true)
            ]),
            'user' => $user
        ));
    }

    public function clientsAction()
    {
        $this->view->pick('client/list');
        Assets::easyUI('js/client.js');
        Template::exists('client', 'list') or die(Main::showMessageModal('配置文件不存在，请先创建！', 109106002));
        $listSearchArr = array();
        $listSearchArr[] = array('type' => 'text', 'id' => 'List_Search', 'label' => ' 搜索： ');
        $userId = $this->request->get('id', 'int');
        $user = Assist::getUserInfo($userId);
        $this->view->setVars(array(
            'List' => Template::createList('List', 'client', [
                //'searchToolbar' => Template::createSearchToolBar($listSearchArr, true)
            ]),
            'user' => $user
        ));
    }

}